AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include('shared.lua')

function ENT:OnRemove()
end

function ENT:KeyValue(key,value)
end

function ENT:Initialize()
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_NONE)
	self.Entity:SetSolid(SOLID_VPHYSICS)
	self.Entity:SetCollisionGroup(COLLISION_GROUP_WEAPON)
	
	//local phys = self.Entity:GetPhysicsObject()
	
	self.nextuse = 0
end

function ENT:Use(activator,caller)
	if (not IsValid(activator)) or (not activator:IsPlayer()) then
		return
	end
	
	local GM = gmod.GetGamemode()
	local id = self.wsUID
	
	local tab = GM.buildingdata[id]
	if not tab then
		error("Somehow, ",self.Entity," does not have a building data table (wsUID: ",id,")\n")
	end
	
	if CurTime() < self.nextuse then
		return
	end
	
	//Show the inventory menu
	GM:BuildingUpdate(tab,activator)
	
	self.nextuse = CurTime()+1
end


function ENT:Think()
end

function ENT:UpdateTransmitState()
	return TRANSMIT_PVS
end
